import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: () => import('@/views/layout/LayoutPage.vue'),
      children: [
        { path: '', component: () => import('@/views/home/HomePage.vue') },
        {
          path: 'category/:id',
          component: () => import('@/views/category/CategoryPage.vue')
        },
        {
          path: 'category/sub/:id',
          component: () => import('@/views/subCategory/SubcategoryPage.vue')
        },
        {
          path: 'detail/:id',
          component: () => import('@/views/detail/DetailPage.vue')
        },
        {
          path: 'cartList',
          component: () => import('@/views/cartList/CartPage.vue')
        },
        {
          path: 'checkout',
          component: () => import('@/views/checkout/CheckoutPage.vue')
        },
        {
          path: 'pay',
          component: () => import('@/views/pay/PayPage.vue')
        }
      ]
    },
    { path: '/login', component: () => import('@/views/login/LoginPage.vue') }
  ],
  scrollBehavior() {
    return {
      top: 0
    }
  }
})

export default router
